/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author cegarciaa
 */
@Entity
@Table(name = "varid")
@NamedQueries({
    @NamedQuery(name = "Varid.findAll", query = "SELECT v FROM Varid v"),
    @NamedQuery(name = "Varid.findByDato", query = "SELECT v FROM Varid v WHERE v.dato = :dato"),
    @NamedQuery(name = "Varid.findByIdvariablei", query = "SELECT v FROM Varid v WHERE v.varidPK.idvariablei = :idvariablei"),
    @NamedQuery(name = "Varid.findByIddispositivo", query = "SELECT v FROM Varid v WHERE v.varidPK.iddispositivo = :iddispositivo")})
public class Varid implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected VaridPK varidPK;
    @Column(name = "DATO")
    private Integer dato;
    @JoinColumn(name = "IDVARIABLEI", referencedColumnName = "IDVARIABLEI", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Variablei variablei;
    @JoinColumn(name = "IDDISPOSITIVO", referencedColumnName = "IDDISPOSITIVO", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Dispositivo dispositivo;

    public Varid() {
    }

    public Varid(VaridPK varidPK) {
        this.varidPK = varidPK;
    }

    public Varid(long idvariablei, long iddispositivo) {
        this.varidPK = new VaridPK(idvariablei, iddispositivo);
    }

    public VaridPK getVaridPK() {
        return varidPK;
    }

    public void setVaridPK(VaridPK varidPK) {
        this.varidPK = varidPK;
    }

    public Integer getDato() {
        return dato;
    }

    public void setDato(Integer dato) {
        this.dato = dato;
    }

    public Variablei getVariablei() {
        return variablei;
    }

    public void setVariablei(Variablei variablei) {
        this.variablei = variablei;
    }

    public Dispositivo getDispositivo() {
        return dispositivo;
    }

    public void setDispositivo(Dispositivo dispositivo) {
        this.dispositivo = dispositivo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (varidPK != null ? varidPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Varid)) {
            return false;
        }
        Varid other = (Varid) object;
        if ((this.varidPK == null && other.varidPK != null) || (this.varidPK != null && !this.varidPK.equals(other.varidPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Varid[varidPK=" + varidPK + "]";
    }

}
